{include file="public/header" /}
<!--main content start-->
<section class="main-content-wrapper">
    <section id="main-content">
        <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">栏目添加</h3>
                    <!--<div class="actions pull-right">-->
                        <!--<i class="fa fa-chevron-down"></i>-->
                        <!--<i class="fa fa-times"></i>-->
                    <!--</div>-->
                </div>
                <div class="panel-body">
                <form action="/admin/column/column_save" method="post" enctype="multipart/form-data" class="form-horizontal form-border">
                    <input name="id" value="{$id|default=''}" type="hidden">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目名称：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="name" value="{$name|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">上级栏目：</label>
                        <div class="col-sm-4">
                            <select class="form-control input-sm" name="column" id="column">
                                <option value="">无</option>
                                {volist name="c_lists" id="vo"}
                                <option value="{$vo.id}" data-type="{$vo.type}" <?php if(isset($c_id)){if($c_id==$vo['id'])echo 'selected';}?>>{$vo.name}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目类型：</label>
                        <div class="col-sm-4">
                            <select class="form-control input-sm" name="type" id="type">
                                <option value="1" class="type_1" {if condition="(isset($type) and $type == 1)"}selected{else /}{/if}>文章</option>
                                <option value="2" class="type_2" {if condition="(isset($type) and $type == 2)"}selected{else /}{/if}>产品</option>
                                <option value="3" class="type_3" {if condition="(isset($type) and $type == 3)"}selected{else /}{/if}>单页</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目关键词：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" name="keywords" placeholder="以英文,分割关键词" value="{$keywords|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目描述：</label>
                        <div class="col-sm-4">
                            <textarea class="form-control" name="describe">{$describe|default=''}</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">栏目图片：</label>
                        <div class="col-sm-8">
                            <div class="col-sm-8">
                                <!--<input type="file" name="img">-->
                                <!--<p class="help-block">建议尺寸150*100.</p>-->
                                <input type="file" name="image" id="imgOne" onchange="preImg(this.id,'imgPre');" />
                                <p class="help-block">建议尺寸150*100.</p>
                                <img id="imgPre" src="{$image|default='/web_admin/img/nopic.png'}" width="150px" height="100px" style="display: block;" />
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">seo栏目名：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" placeholder="请填写英文" name="seo_name_en" value="{$seo_name_en|default=''}">
                        </div>
                    </div>
                    <div class="panel-body">
                        <button type="submit" class="btn btn_5 btn-lg btn-default w_update">发布</button>
                    </div>
                </form>
                </div>
            </div>
        </div>
        </div>
    </section>
</section>
<style>
    @media (min-width: 768px){
        .form-horizontal .control-label {
             text-align: left;
        }
    }

</style>
<script>
    $("#column").bind('change',function(){
        var type=$("#column option:selected").attr('data-type');
        if(type==1){
            $(".type_1").attr('selected','selected');
        }else if(type==2){
            $(".type_2").attr('selected','selected');
        }else{
            $(".type_1").attr('selected','selected');
        }
    })
    $("#type").bind('change',function(){
        var type=$("#type option:selected").val();
        var type_html=$("#type option:selected").html();
        var c_type=$("#column option:selected").attr('data-type');
        if(type!=c_type){
            if(c_type>0){
                alert('上级栏目不是'+type_html+'类型,您无法选择该类型。');
                $(".type_"+c_type).attr('selected','selected');
            }
        }
    })
</script>
<script>
    /**
     * 从 file 域获取 本地图片 url
     */
    function getFileUrl(sourceId) {
        var url;
        if (navigator.userAgent.indexOf("MSIE")>=1) { // IE
            url = document.getElementById(sourceId).value;
        } else if(navigator.userAgent.indexOf("Firefox")>0) { // Firefox
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        } else if(navigator.userAgent.indexOf("Chrome")>0) { // Chrome
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        }
        return url;
    }
    /**
     * 将本地图片 显示到浏览器上
     */
    function preImg(sourceId, targetId) {
        var url = getFileUrl(sourceId);
        var imgPre = document.getElementById(targetId);
        imgPre.src = url;
    }
</script>
<!--main content end-->
{include file="public/footer" /}